#include <stdio.h>

int main(int argc, char const *argv[])
{
    long n, x, i, j, result = 0;
    scanf("%ld%ld", &n, &x);
    for (i = 1; i <= n; i++)
    {
        j = i;
        do
        {
            if (j % 10 == x)
            {
                result++;
            }
            j /= 10;
        } while (j);
    }
    printf("%ld", result);
    return 0;
}
